home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
os2
/
e33el2.zip
/
emacs
/
19.33
/
lisp
/
browse-url.el
< prev
next >
Wrap
Text File
|
1996-08-04
|
24KB
|
606 lines
;;; browse-url.el --- ask a WWW browser to load a URL
;; Copyright 1995, 1996 Free Software Foundation, Inc.
;; Author: Denis Howe <dbh@doc.ic.ac.uk>
;; Maintainer: Denis Howe <dbh@doc.ic.ac.uk>
;; Created: 03 Apr 1995
;; Keywords: hypertext
;; X-Home page: http://wombat.doc.ic.ac.uk/
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; The latest version of this package should be available from
;; <URL:http://wombat.doc.ic.ac.uk/emacs/browse-url.el>.
;; This package provides functions which read a URL (Uniform Resource
;; Locator) from the minibuffer, defaulting to the URL around point,
;; and ask a World-Wide Web browser to load it. It can also load the
;; URL associated with the current buffer. Different browsers use
;; different methods of remote control so there is one function for
;; each supported browser. If the chosen browser is not running, it
;; is started. Currently there is support for:
;; Function Browser Earliest version
;; browse-url-netscape Netscape 1.1b1
;; browse-url-mosaic XMosaic <= 2.4
;; browse-url-cci XMosaic 2.5
;; browse-url-w3 w3 0
;; browse-url-iximosaic IXI Mosaic ?
;; Note that versions of Netscape before 1.1b1 did not have remote
;; control. <URL:http://home.netscape.com/newsref/std/x-remote.html>
;; and <URL:http://home.netscape.com/info/APIs/>.
;; Netscape can cache Web pages so it may be necessary to tell it to
;; reload the current page if it has changed (eg. if you have edited
;; it). There is currently no perfect automatic solution to this.
;; Netscape allows you to specify the id of the window you want to
;; control but which window DO you want to control and how do you
;; discover its id?
;; If using XMosaic before version 2.5, check the definition of
;; browse-url-usr1-signal below.
;; <URL:http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/remote-control.html>
;; XMosaic version 2.5 introduced Common Client Interface allowing you
;; to control mosaic through Unix sockets.
;; <URL:http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/CCI/cci-spec.html>
;; William M. Perry's excellent "w3" WWW browser for
;; Emacs <URL:ftp://cs.indiana.edu/pub/elisp/w3/>
;; has a function w3-follow-url-at-point, but that
;; doesn't let you edit the URL like browse-url.
;; I recommend Nelson Minar <nelson@santafe.edu>'s excellent
;; html-helper-mode.el for editing HTML and thank Nelson for
;; his many useful comments on this code.
;; <URL:http://www.santafe.edu/~nelson/hhm-beta/>
;; This package generalises function html-previewer-process in Marc
;; Andreessen <marca@ncsa.uiuc.edu>'s html-mode (LCD
;; modes/html-mode.el.Z) and provides better versions of the URL
;; functions in Michelangelo Grigni <mic@cs.ucsd.edu>'s ffap.el
;; (find-file-at-point) <URL:ftp://cs.ucsd.edu:/pub/mic/>. The huge
;; hyperbole package also contains similar functions.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Help!
;; Can you write and test some code for the Macintrash and Windoze
;; Netscape remote control APIs? (See the URL above).
;; Do any other browsers have remote control?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Usage
;; To display the URL at or before point:
;; M-x browse-url-at-point RET
;; To display a URL by shift-clicking on it, put this in your ~/.emacs
;; file:
;; (global-set-key [S-mouse-2] 'browse-url-at-mouse)
;; (Note that using Shift-mouse-1 is not desirable because
;; that event has a standard meaning in Emacs.)
;; To display the current buffer in a web browser:
;; M-x browse-url-of-buffer RET
;; In Dired, to display the file named on the current line:
;; M-x browse-url-of-dired-file RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Customisation (~/.emacs)
;; To see what variables are available for customization, type `M-x
;; set-variable browse-url TAB'.
;; To bind the browse-url commands to keys with the `C-c u' prefix:
;; (global-set-key "\C-cu." 'browse-url-at-point)
;; (global-set-key "\C-cub" 'browse-url-of-buffer)
;; (global-set-key "\C-cuf" 'browse-url-of-file)
;; (add-hook 'dired-mode-hook
;; (lambda ()
;; (local-set-key "\C-cuf" 'browse-url-of-dired-file))))
;; (if (boundp 'browse-url-browser-function)
;; (global-set-key "\C-cuu" browse-url-browser-function)
;; (eval-after-load
;; "browse-url"
;; '(global-set-key "\C-cuu" browse-url-browser-function)))
;; To use the Emacs w3 browser when not running under X11:
;; (if (not (eq window-system 'x))
;; (setq browse-url-browser-function 'browse-url-w3))
;; To always save modified buffers before displaying the file in a browser:
;; (setq browse-url-save-file t)
;; To get round the Netscape caching problem, you could try either of
;; the following (but not both). EITHER write-file in
;; html-helper-mode makes Netscape reload document:
;;
;; (autoload 'browse-url-netscape-reload "browse-url"
;; "Ask a WWW browser to redisplay the current file." t)
;; (add-hook 'html-helper-mode-hook
;; (function (lambda ()
;; (add-hook 'local-write-file-hooks
;; (function (lambda ()
;; (let ((local-write-file-hooks))
;; (save-buffer))
;; (browse-url-netscape-reload)
;; t)) ; => file written by hook
;; t)))) ; append to l-w-f-hooks
;;
;; [Does this work for html-mode too?]
;;
;; OR browse-url-of-file ask Netscape to load and then reload the
;; file:
;;
;; (add-hook 'browse-url-of-file-hook 'browse-url-netscape-reload)
;; You may also want to customise browse-url-netscape-arguments, eg.
;;
;; (setq browse-url-netscape-arguments '("-install"))
;;
;; or similarly for the other browsers.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Change Log:
;; 0.00 03 Apr 1995 Denis Howe <dbh@doc.ic.ac.uk>
;; Created.
;; 0.01 04 Apr 1995
;; All names start with "browse-url-". Added provide.
;; 0.02 05 Apr 1995
;; Save file at start of browse-url-of-file.
;; Use start-process instead of start-process-shell-command.
;; 0.03 06 Apr 1995
;; Add browse-url-netscape-reload, browse-url-netscape-command.
;; browse-url-of-file save file option.
;; 0.04 08 Apr 1995
;; b-u-file-url separate function. Change b-u-filename-alist
;; default.
;; 0.05 09 Apr 1995
;; Added b-u-of-file-hook.
;; 0.06 11 Apr 1995
;; Improved .emacs suggestions and documentation.
;; 0.07 13 Apr 1995
;; Added browse-url-interactive-arg optional prompt.
;; 0.08 18 Apr 1995
;; Exclude final "." from browse-url-regexp.
;; 0.09 21 Apr 1995
;; Added mouse-set-point to browse-url-interactive-arg.
;; 0.10 24 Apr 1995
;; Added Mosaic signal sending variations.
;; Thanks Brian K Servis <servis@ecn.purdue.edu>.
;; Don't use xprop for Netscape.
;; 0.11 25 Apr 1995
;; Fix reading of ~/.mosaicpid. Thanks Dag.H.Wanvik@kvatro.no.
;; 0.12 27 Apr 1995
;; Interacti